#include "stdafx.h"
#include "BuffDef.h"
#include "InstanceTouch.h"

DECL_INSTANCE_TOUCH(ETouch_BuffDef);

struct BuffDefReflectionRegister
{
	BuffDefReflectionRegister()
	{
		REGISTER_REFLECTION_MEMBER(BuffDef,m_iID,INVALID_ID).Editor_SetAsPrimaryKey();
		REGISTER_REFLECTION_MEMBER(BuffDef,m_sDisplayName,std::string("DefaultDisplayName")).Editor_SetAsDisplayName();
		REGISTER_REFLECTION_MEMBER(BuffDef,m_iBuffType,INVALID_ID).Editor_SetAsForeignKey(eDefGroup_Default,eDefaultDef_BuffType);
		REGISTER_REFLECTION_MEMBER(BuffDef,m_sGameName,std::string("GameName")).Editor_SetAsRaw();
		REGISTER_REFLECTION_MEMBER(BuffDef,m_iLvl,0).Editor_SetAsRaw();
		REGISTER_REFLECTION_MEMBER(BuffDef,m_bForCombat,false).Editor_SetAsRaw();
		REGISTER_REFLECTION_MEMBER(BuffDef,m_bCoutTimeOffLine,false).Editor_SetAsRaw();		
		REGISTER_REFLECTION_MEMBER(BuffDef,m_bIsShowOnClient,true).Editor_SetAsRaw();
		REGISTER_REFLECTION_MEMBER(BuffDef,m_bIsSaveToDB,true).Editor_SetAsRaw();
		REGISTER_REFLECTION_MEMBER(BuffDef,m_iClientResID,0).Editor_SetAsRaw();		
		REGISTER_REFLECTION_MEMBER(BuffDef,m_eCountTimeMod,eBuffCountTimeMod_ElapseDuration).Editor_SetAsEnumation<EBuffCountTimeMod>();
		REGISTER_REFLECTION_MEMBER(BuffDef,m_iDurationSec,0).Editor_SetAsRaw();
		REGISTER_REFLECTION_MEMBER(BuffDef,m_sEndTimePoint,std::string("2013/12/01 12:00:00")).Editor_SetAsRaw();
		REGISTER_REFLECTION_MEMBER(BuffDef,m_vExcludeTypes,std::vector<int32>()).Editor_SetAsForeignKeySet(eDefGroup_Default,eDefaultDef_BuffType);
		REGISTER_REFLECTION_MEMBER(BuffDef,m_bReplaceByLvlWhenSameType,false).Editor_SetAsRaw();
		REGISTER_REFLECTION_MEMBER(BuffDef,m_eModifier1,eBuffModifyer_NULL).Editor_SetAsEnumation<EValueModifyer>("Mod1");
		REGISTER_REFLECTION_MEMBER(BuffDef,m_fAddValue1,double(0.f)).Editor_SetAsRaw("Mod1");
		REGISTER_REFLECTION_MEMBER(BuffDef,m_fAddPercent1,double(0.f)).Editor_SetAsRaw("Mod1");
		REGISTER_REFLECTION_MEMBER(BuffDef,m_eModifier2,eBuffModifyer_NULL).Editor_SetAsEnumation<EValueModifyer>("Mod2");
		REGISTER_REFLECTION_MEMBER(BuffDef,m_fAddValue2,double(0.f)).Editor_SetAsRaw("Mod2");
		REGISTER_REFLECTION_MEMBER(BuffDef,m_fAddPercent2,double(0.f)).Editor_SetAsRaw("Mod2");
		
		REGISTER_REFLECTION_MEMBER(BuffDef,m_sDesc,std::string("BuffDesc")).Editor_SetAsRaw();


		GlobalClassManager::Instance().RegisterClass(BuffDef::s_GetReflection(),eDefaultDef_Buff);
		GlobalDefManager::Instance().RegisterDefManger(&BuffDefManager::Instance());
	}
}____buffdefreflectionregister;

rewrite  void BuffDef::OnArchieveReaded()
{
		m_iEndTimePoint=(int32)Util::PraseISOTimeString(m_sEndTimePoint.c_str());
		m_vModifiers.clear();
		if(m_eModifier1!=eBuffModifyer_NULL)
		{
			ValueModifier modifier;
			modifier.m_eModifier=m_eModifier1;
			modifier.m_fAddValue=m_fAddValue1;
			modifier.m_fAddPercent=m_fAddPercent1;
			m_vModifiers.push_back(modifier);
		}
		if(m_eModifier2!=eBuffModifyer_NULL)
		{
			ValueModifier modifier;
			modifier.m_eModifier=m_eModifier2;
			modifier.m_fAddValue=m_fAddValue2;
			modifier.m_fAddPercent=m_fAddPercent2;
			m_vModifiers.push_back(modifier);
		}
}